var FunEngine = require('./FunEngine.js');
import * as THREE from './three.js';

var winWidth;
var winHeight;
var CurrentIndex = 0;

var circlePosArray = [55 - 96, 55, 151, 247, 247 + 96];

var STATE = {
  NONE: -1,
  TOUCH_ROTATE: 0,
  TOUCH_ZOOM_PAN: 1,
  TOUCH_PAN: 2
};

var _state = STATE.NONE;
var _movePrev = new THREE.Vector2();
var _moveCurr = new THREE.Vector2();
var _touchZoomDistanceStart = 1;
var _touchZoomDistanceEnd = 1;
var _panStart = new THREE.Vector2();
var _panEnd = new THREE.Vector2();

var lookAtPos = new THREE.Vector3(1000, 1000, 0);


function getMouseOnScreen(pageX, pageY) {
  var vector = new THREE.Vector2();

  vector.set(
    (pageX) / winWidth,
    (pageY) / winHeight
  );

  return vector;
}

function getMouseOnCircle(pageX, pageY) {
  var vector = new THREE.Vector2();
  vector.set(
    ((pageX - winWidth * 0.5) / (winWidth * 0.5)),
    ((winHeight + 2 * (0 - pageY)) / winWidth)
  );

  return vector;
}

Page({
  data: {
    debugStr: "debugStr",
    motionStr: '',
    gyroscopeStr: '',


    lastAlpha: 0,
    lastBeta: 0,
    lastGamma: 0,
    motionAlphaStr: '',

    lastArCameraDataTimestamp: -1,
    gyroscopeX: 0,
    gyroscopeY: 0,
    gyroscopeZ: 0,
    fliterMotion: false,
    isMotion: true,
    lookAtX: 0,
    lookAtY: 0,
    lookAtZ: 0,
  },

  onFliterMotionClick(e) {
    var tempFliter = this.data.fliterMotion;
    this.setData({
      fliterMotion: !tempFliter
    })
  },

  onIsMotionClick(e) {
    var tempIsMotion = this.data.isMotion;
    this.setData({
      isMotion: !tempIsMotion
    })
  },

  consoleLogToScreen(inStr) {
    var str = this.data.debugStr + "\n";
    str += inStr;
    this.setData({
      debugStr: str
    })
  },

  onLoad(query) {
    // 页面加载
    console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
    this.consoleLogToScreen("onLoad")
  },
  canvasStart: function (event) {
    var clickTag = FunEngine.GetClickedTag(event);
    if (clickTag == 'seq') {
      my.alert({ content: clickTag });
      return;
    }

    switch (event.touches.length) {

      case 1:
        _state = STATE.TOUCH_ROTATE;
        _moveCurr.copy(getMouseOnCircle(event.touches[0].x, event.touches[0].y));
        _movePrev.copy(_moveCurr);
        break;
      case 2:
        // _state = STATE.TOUCH_ZOOM_PAN;
        // var dx = event.touches[0].x - event.touches[1].x;
        // var dy = event.touches[0].y - event.touches[1].y;
        // _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);


        // var x = (event.touches[0].x + event.touches[1].x) / 2;
        // var y = (event.touches[0].y + event.touches[1].y) / 2;
        // _panStart.copy(getMouseOnScreen(x, y));
        break;
      default:
        _state = STATE.TOUCH_PAN;
        var x = (event.touches[0].x + event.touches[1].x) / 2;
        var y = (event.touches[0].y + event.touches[1].y) / 2;
        _panStart.copy(getMouseOnScreen(x, y));
        _panEnd.copy(_panStart);
        break;
    }
    return;


    //my.alert({content: tagName});
  },
  canvasMove: function (event) {
    switch (event.touches.length) {
      case 1:
        if (_state === STATE.TOUCH_ROTATE) {

          _movePrev.copy(_moveCurr);
          //my.alert({content: event.touches[0]});
          _moveCurr.copy(getMouseOnCircle(event.touches[0].x, event.touches[0].y));
          //_moveCurr.copy(new THREE.Vector2(event.touches[0].x, event.touches[0].y));

          var xOffset = _moveCurr.x - _movePrev.x;
          var yOffset = _moveCurr.y - _movePrev.y;
          if (_state == STATE.TOUCH_ROTATE) {
            xOffset *= 1;
            yOffset *= 1;
          }
          //my.alert({content: xOffset});
          FunEngine.SetSceneRot(xOffset, yOffset);
          //my.alert({content: xOffset});
        }
        //console.log(_moveCurr);
        break;
      default:
        _state = STATE.TOUCH_ZOOM_PAN;
        var dx = event.touches[0].x - event.touches[1].x;
        var dy = event.touches[0].y - event.touches[1].y;

        if (_touchZoomDistanceStart < 1.001 && _touchZoomDistanceStart > 0.999 && _touchZoomDistanceEnd < 1.001 && _touchZoomDistanceEnd > 0.999) {
          _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
        } else {
          _touchZoomDistanceEnd = parseInt(Math.sqrt(dx * dx + dy * dy));
        }

        break;
    }
  },
  canvasEnd: function (event) {
    switch (event.touches.length) {
      case 0:
        _state = STATE.NONE;
        _touchZoomDistanceEnd = _touchZoomDistanceStart = 1;
        break;
      default:
        _state = STATE.NONE;
        _moveCurr.copy(getMouseOnCircle(event.touches[0].x, event.touches[0].y));
        _movePrev.copy(_moveCurr);
        _panStart.copy(_panEnd);
        break;
    }
  },
  onReady() {
    // 页面加载完成
    var self = this

    my.getLocation({
      success(res) {
        my.hideLoading();
        console.log(res)
        that.setData({
          hasLocation: true,
          location: formatLocation(res.longitude, res.latitude)
        })
      },
      fail() {
        my.hideLoading();

        my.alert({ title: '定位失败' });
      },
    })
    return;

    /**
     * 手机方向
     */
    my.onDeviceMotionChange(function (res) {
      if (!self.data.isMotion)
        return;

      var timestamp = (new Date()).valueOf();

      var alpha = res.alpha;
      var beta = res.beta;
      var gamma = res.gamma;
      var saveAlpha = true;
      var saveBeta = true;
      var saveGamma = true;

      var alphaGap = (180 / Math.PI) * Math.abs(alpha - self.data.lastAlpha);


      alpha = alpha.toFixed(2);
      beta = beta.toFixed(2);
      gamma = gamma.toFixed(2);


      var tempFliter = self.data.fliterMotion;

      if (beta < -0.87) {
        beta = -0.87;
      } else if (beta > 0.87) {
        beta = 0.87;
      }

      //////////根据角度差过滤///////////
      var fliterRotLookAt = function (preParam, tempParam) {
        var rotaio = 0.09;
        var result = { param: 0.0, save: true }
        if (Math.abs(tempParam - preParam) < rotaio) {
          result.param = preParam += (tempParam - preParam) * 0.3
          result.save = false;
        } else {
          result.param = tempParam
          result.save = true;
        }
        return result;
      }

      if (tempFliter) {
        var alphaData = fliterRotLookAt(self.data.lastAlpha, alpha)
        alpha = alphaData.param;
        saveAlpha = alphaData.save;
        var betaData = fliterRotLookAt(self.data.lastBeta, beta)
        beta = betaData.param;
        saveBeta = betaData.save;
        var gammaData = fliterRotLookAt(self.data.lastGamma, gamma)
        gamma = gammaData.param;
        saveGamma = gammaData.save;
      }

      // var fliterRatio = 0.01
      // if (tempFliter && (Math.abs(self.data.lastAlpha - alpha) < fliterRatio || Math.abs(self.data.lastBeta - beta) < fliterRatio
      //   || Math.abs(self.data.lastGamma - gamma) < fliterRatio)) {
      //   // alpha = res.alpha * 0.001;
      //   // beta = res.beta * 1;
      //   // gamma = res.gamma * 0.001;
      //   // saveData = false;
      //   return;
      // }
      //////////////////////////////////////
      if (timestamp - self.data.lastArCameraDataTimestamp < 80)
        return;

      if (tempFliter)
        var axisX = Math.sin(alpha) * Math.cos(beta);
      else
        var axisX = Math.sin(alpha) /* * Math.cos(beta) */;

      var axisY = Math.cos(alpha) /* * Math.sin(beta) */;
      var axisZ = 0;
      // var axisZ = sin(alpha) * sin(beta)
      // var axisZ = 0 - Math.cos(beta - (Math.PI / 6)); // * Math.cos(gamma)

      //       lookAtX: 0,
      // lookAtY: 0,
      // lookAtZ: 0,



      //////// 根据lookat点的距离差过滤   不合适 /////////      
      // var lastLookAtX = self.data.lookAtX;
      // var lastLookAtY = self.data.lookAtY;
      // var lastLookAtZ = self.data.lookAtZ;

      // var fliterLookAt = function (preParam, tempParam) {
      //   var rotaio = 0.001;
      //   if (tempParam - preParam < rotaio) {
      //     return preParam += (tempParam - preParam) * 0.1
      //   } else
      //     return tempParam;
      // }

      // if (tempFliter) {
      //   axisX = fliterLookAt(lastLookAtX, axisX)
      //   axisY = fliterLookAt(lastLookAtY, axisY)
      //   axisZ = fliterLookAt(lastLookAtZ, axisZ)
      // }
      ///////////////////////////////////////////////////

      FunEngine.SetSceneRotTest(axisX, axisY, axisZ);

      self.setData({
        motionStr: "alphaGap = " + alphaGap,
      })

      if (saveAlpha) {
        self.setData({
          lastAlpha: res.alpha,
        })
      }

      if (saveBeta) {
        self.setData({
          lastBeta: res.beta,
        })
      }

      if (saveGamma) {
        self.setData({
          lastGamma: res.gamma,
        })
      }

    })

    /**
     * 陀螺仪
     */
    my.onGyroscopeChange(function (res) {
      if (self.data.isMotion)
        return;

      var timestamp = (new Date()).valueOf();
      var curx = res.x;
      var cury = res.y;
      var curz = res.z;

      var speedParam = 1;
      if (self.data.lastArCameraDataTimestamp != -1) {
        var lastTime = self.data.lastArCameraDataTimestamp;
        var timeGap = timestamp - lastTime;

        var radiusGapX = timeGap * curx * speedParam;
        var radiusGapY = timeGap * cury * speedParam;
        var radiusGapZ = timeGap * curz * speedParam;

        self.setData({
          lastArCameraDataTimestamp: timestamp,
        })

        // lookAtPos
        var axisX = Math.sin(radiusGapY) * 100;
        var axisY = Math.cos(radiusGapY) * 100;



        lookAtPos.x += axisX;
        lookAtPos.y += axisY;

        self.setData({
          gyroscopeStr: "lookAtPos = " + lookAtPos.x + "   " + lookAtPos.y,
        })


        FunEngine.SetSceneRotTest(lookAtPos.x, lookAtPos.y, 0);


      } else {
        self.setData({
          lastArCameraDataTimestamp: timestamp,
          // gyroscopeX: resX,
          // gyroscopeY: resY,
          // gyroscopeZ: resZ,
        })
      }
    });
  },

  SwitchScene() {
    if (CurrentIndex == 0) {
      FunEngine.SwitchSkyBox('tag1', 'tag0', 2000);
      CurrentIndex = 1;
    } else {
      FunEngine.SwitchSkyBox('tag0', 'tag1', 2000);
      CurrentIndex = 0;
    }

  },
  onShow() {
    // 页面显示
    var res = my.getSystemInfoSync();
    console.log(res);
    const { windowWidth, windowHeight } = res;
    this.setData({
      windowWidth,
      windowHeight
    }, () => {
      winWidth = windowWidth;
      winHeight = windowHeight;

      console.log([windowWidth, windowHeight]);
      FunEngine.InitEngine('canvasGL');

      //FunEngine.AddImage('back',0,0,windowWidth,windowHeight,'https://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/model/back-img.png');

      var urls = ['http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano2/pano_f.png', 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano2/pano_b.png',
        'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano2/pano_r.png', 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano2/pano_l.png',
        'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano2/pano_u.png', 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano2/pano_d.png'];

      FunEngine.AddSkyBox(urls, 'tag0');


      //   var urls1 = ['http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano1/pano_f.png', 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano1/pano_b.png',
      // 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano1/pano_r.png', 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano1/pano_l.png',
      // 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano1/pano_u.png', 'http://morefun-active.oss-cn-beijing.aliyuncs.com/tmp/pano1/pano_d.png'];

      //  FunEngine.AddSkyBox(urls1,'tag1');

      //  var jsonData = {"frames":{"0001.jpg":{"frame":{"x":2257,"y":3341,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0002.jpg":{"frame":{"x":2633,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0003.jpg":{"frame":{"x":2257,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0004.jpg":{"frame":{"x":2633,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0005.jpg":{"frame":{"x":2257,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0006.jpg":{"frame":{"x":1881,"y":3341,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0007.jpg":{"frame":{"x":1881,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0008.jpg":{"frame":{"x":2633,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0009.jpg":{"frame":{"x":2257,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0010.jpg":{"frame":{"x":1881,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0011.jpg":{"frame":{"x":1505,"y":3341,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0012.jpg":{"frame":{"x":1505,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0013.jpg":{"frame":{"x":2633,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0014.jpg":{"frame":{"x":2257,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0015.jpg":{"frame":{"x":1881,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0016.jpg":{"frame":{"x":1505,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0017.jpg":{"frame":{"x":1129,"y":3341,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0018.jpg":{"frame":{"x":1129,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0019.jpg":{"frame":{"x":2633,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0020.jpg":{"frame":{"x":2257,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0021.jpg":{"frame":{"x":1881,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0022.jpg":{"frame":{"x":1505,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0023.jpg":{"frame":{"x":1129,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0024.jpg":{"frame":{"x":753,"y":3341,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0025.jpg":{"frame":{"x":753,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0026.jpg":{"frame":{"x":1881,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0027.jpg":{"frame":{"x":1505,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0028.jpg":{"frame":{"x":1129,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0029.jpg":{"frame":{"x":753,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0030.jpg":{"frame":{"x":377,"y":3341,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0031.jpg":{"frame":{"x":377,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0032.jpg":{"frame":{"x":1505,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0033.jpg":{"frame":{"x":1129,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0034.jpg":{"frame":{"x":753,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0035.jpg":{"frame":{"x":377,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0036.jpg":{"frame":{"x":1,"y":3341,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0037.jpg":{"frame":{"x":1,"y":2673,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0038.jpg":{"frame":{"x":1129,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0039.jpg":{"frame":{"x":753,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0040.jpg":{"frame":{"x":377,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0041.jpg":{"frame":{"x":1,"y":2005,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0042.jpg":{"frame":{"x":753,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0043.jpg":{"frame":{"x":377,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0044.jpg":{"frame":{"x":1,"y":1337,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0045.jpg":{"frame":{"x":377,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0046.jpg":{"frame":{"x":1,"y":669,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}},"0047.jpg":{"frame":{"x":1,"y":1,"w":375,"h":667},"rotated":false,"trimmed":false,"spriteSourceSize":{"x":0,"y":0,"w":375,"h":667},"sourceSize":{"w":375,"h":667}}},"meta":{"app":"http://www.texturepacker.com","version":"1.0","image":"https://morefun-active.oss-cn-beijing.aliyuncs.com/osm/images/seq/1334.png","format":"RGBA8888","size":{"w":3009,"h":4009},"scale":"0.5","smartupdate":"$TexturePacker:SmartUpdate:e678ef8102ed9ddd31cbef3d0d4f817d$"}};
      //   var aniData = [];
      //   for(var i=1; i<10; i++)
      //   { 
      //     aniData.push('000'+i+'.jpg');
      //   }
      //   for(var i=10; i<48; i++)
      //   { 
      //     aniData.push('00'+i+'.jpg');
      //   }
      //   FunEngine.AddSprite('seq',-200,0,50,112*0.2,244*0.2,jsonData,'https://morefun-active.oss-cn-beijing.aliyuncs.com/osm/images/seq/1334.png',aniData,5);


    });


  },
  onHide() {
    // 页面隐藏
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
});
